package com.secret.chain.secretchain.solidity;

import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple5;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple6;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@SuppressWarnings("unchecked")
public class Article extends Contract {
    public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b50610781806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c806396f6f9421161008c578063dbf89bd311610066578063dbf89bd314610440578063e58324ea1461045e578063e5a0af3d1461047c578063efc81a8c1461049a576100cf565b806396f6f94214610294578063a0f44c9214610404578063a2e6204514610422576100cf565b8063200d2ed2146100d45780634a79d50c146100f25780634c53790e1461017557806371d305e81461019357806376a58e9a146101f35780638a4d5a6714610211575b600080fd5b6100dc6104b8565b6040518082815260200191505060405180910390f35b6100fa6104be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013a57808201518184015260208101905061011f565b50505050905090810190601f1680156101675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d61055c565b6040518082815260200191505060405180910390f35b6101f1600480360360c08110156101a957600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610562565b005b6101fb610594565b6040518082815260200191505060405180910390f35b61021961059a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561025957808201518184015260208101905061023e565b50505050905090810190601f1680156102865780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610402600480360360a08110156102aa57600080fd5b810190808035906020019092919080359060200190929190803590602001906401000000008111156102db57600080fd5b8201836020820111156102ed57600080fd5b8035906020019184600183028401116401000000008311171561030f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561037257600080fd5b82018360208201111561038457600080fd5b803590602001918460018302840111640100000000831117156103a657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610638565b005b61040c610682565b6040518082815260200191505060405180910390f35b61042a610688565b6040518082815260200191505060405180910390f35b61044861068e565b6040518082815260200191505060405180910390f35b610466610694565b6040518082815260200191505060405180910390f35b61048461069a565b6040518082815260200191505060405180910390f35b6104a26106a0565b6040518082815260200191505060405180910390f35b600a5481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105545780601f1061052957610100808354040283529160200191610554565b820191906000526020600020905b81548152906001019060200180831161053757829003601f168201915b505050505081565b60055481565b856004819055508460058190555083600681905550826007819055508160098190555080600a81905550505050505050565b60065481565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106305780601f1061060557610100808354040283529160200191610630565b820191906000526020600020905b81548152906001019060200180831161061357829003601f168201915b505050505081565b8460008190555083600181905550826002908051906020019061065c9291906106a6565b5081600390805190602001906106739291906106a6565b50806008819055505050505050565b60015481565b60095481565b60075481565b60005481565b60045481565b60085481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106e757805160ff1916838001178555610715565b82800160010185558215610715579182015b828111156107145782518255916020019190600101906106f9565b5b5090506107229190610726565b5090565b61074891905b8082111561074457600081600090555060010161072c565b5090565b9056fea26469706673582212201a9b1ba72cc71d5d3079f0932ff944746cfbc0f01a9bad402580ad5386db615c64736f6c634300060a0033"};

    public static final String BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {"608060405234801561001057600080fd5b50610781806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c806396f6f9421161008c578063dbf89bd311610066578063dbf89bd314610440578063e58324ea1461045e578063e5a0af3d1461047c578063efc81a8c1461049a576100cf565b806396f6f94214610294578063a0f44c9214610404578063a2e6204514610422576100cf565b8063200d2ed2146100d45780634a79d50c146100f25780634c53790e1461017557806371d305e81461019357806376a58e9a146101f35780638a4d5a6714610211575b600080fd5b6100dc6104b8565b6040518082815260200191505060405180910390f35b6100fa6104be565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013a57808201518184015260208101905061011f565b50505050905090810190601f1680156101675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d61055c565b6040518082815260200191505060405180910390f35b6101f1600480360360c08110156101a957600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610562565b005b6101fb610594565b6040518082815260200191505060405180910390f35b61021961059a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561025957808201518184015260208101905061023e565b50505050905090810190601f1680156102865780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610402600480360360a08110156102aa57600080fd5b810190808035906020019092919080359060200190929190803590602001906401000000008111156102db57600080fd5b8201836020820111156102ed57600080fd5b8035906020019184600183028401116401000000008311171561030f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561037257600080fd5b82018360208201111561038457600080fd5b803590602001918460018302840111640100000000831117156103a657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610638565b005b61040c610682565b6040518082815260200191505060405180910390f35b61042a610688565b6040518082815260200191505060405180910390f35b61044861068e565b6040518082815260200191505060405180910390f35b610466610694565b6040518082815260200191505060405180910390f35b61048461069a565b6040518082815260200191505060405180910390f35b6104a26106a0565b6040518082815260200191505060405180910390f35b600a5481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105545780601f1061052957610100808354040283529160200191610554565b820191906000526020600020905b81548152906001019060200180831161053757829003601f168201915b505050505081565b60055481565b856004819055508460058190555083600681905550826007819055508160098190555080600a81905550505050505050565b60065481565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106305780601f1061060557610100808354040283529160200191610630565b820191906000526020600020905b81548152906001019060200180831161061357829003601f168201915b505050505081565b8460008190555083600181905550826002908051906020019061065c9291906106a6565b5081600390805190602001906106739291906106a6565b50806008819055505050505050565b60015481565b60095481565b60075481565b60005481565b60045481565b60085481565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106106e757805160ff1916838001178555610715565b82800160010185558215610715579182015b828111156107145782518255916020019190600101906106f9565b5b5090506107229190610726565b5090565b61074891905b8082111561074457600081600090555060010161072c565b5090565b9056fea26469706673582212201a9b1ba72cc71d5d3079f0932ff944746cfbc0f01a9bad402580ad5386db615c64736f6c634300060a0033"};

    public static final String SM_BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"name\":\"collectCount\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"collectCount()\"},{\"name\":\"content\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"indexed\":false,\"components\":null,\"typeAsString\":\"string\"}],\"methodSignatureAsString\":\"content()\"},{\"name\":\"create\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"create()\"},{\"name\":\"creatorId\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"creatorId()\"},{\"name\":\"forwardCount\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"forwardCount()\"},{\"name\":\"groupId\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"groupId()\"},{\"name\":\"likeCount\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"likeCount()\"},{\"name\":\"readCount\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"readCount()\"},{\"name\":\"set1\",\"type\":\"function\",\"constant\":false,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"_creatorId\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_groupId\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_title\",\"type\":\"string\",\"indexed\":false,\"components\":null,\"typeAsString\":\"string\"},{\"name\":\"_content\",\"type\":\"string\",\"indexed\":false,\"components\":null,\"typeAsString\":\"string\"},{\"name\":\"_create\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"outputs\":[],\"methodSignatureAsString\":\"set1(uint256,uint256,string,string,uint256)\"},{\"name\":\"set2\",\"type\":\"function\",\"constant\":false,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"_likeCount\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_collectCount\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_forwardCount\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_readCount\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_update\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"},{\"name\":\"_status\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"outputs\":[],\"methodSignatureAsString\":\"set2(uint256,uint256,uint256,uint256,uint256,uint256)\"},{\"name\":\"status\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"status()\"},{\"name\":\"title\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"indexed\":false,\"components\":null,\"typeAsString\":\"string\"}],\"methodSignatureAsString\":\"title()\"},{\"name\":\"update\",\"type\":\"function\",\"constant\":true,\"payable\":false,\"anonymous\":false,\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"indexed\":false,\"components\":null,\"typeAsString\":\"uint256\"}],\"methodSignatureAsString\":\"update()\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_COLLECTCOUNT = "collectCount";

    public static final String FUNC_CONTENT = "content";

    public static final String FUNC_CREATE = "create";

    public static final String FUNC_CREATORID = "creatorId";

    public static final String FUNC_FORWARDCOUNT = "forwardCount";

    public static final String FUNC_GROUPID = "groupId";

    public static final String FUNC_LIKECOUNT = "likeCount";

    public static final String FUNC_READCOUNT = "readCount";

    public static final String FUNC_SET1 = "set1";

    public static final String FUNC_SET2 = "set2";

    public static final String FUNC_STATUS = "status";

    public static final String FUNC_TITLE = "title";

    public static final String FUNC_UPDATE = "update";

    protected Article(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public BigInteger collectCount() throws ContractException {
        final Function function = new Function(FUNC_COLLECTCOUNT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public String content() throws ContractException {
        final Function function = new Function(FUNC_CONTENT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public BigInteger create() throws ContractException {
        final Function function = new Function(FUNC_CREATE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger creatorId() throws ContractException {
        final Function function = new Function(FUNC_CREATORID, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger forwardCount() throws ContractException {
        final Function function = new Function(FUNC_FORWARDCOUNT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger groupId() throws ContractException {
        final Function function = new Function(FUNC_GROUPID, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger likeCount() throws ContractException {
        final Function function = new Function(FUNC_LIKECOUNT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public BigInteger readCount() throws ContractException {
        final Function function = new Function(FUNC_READCOUNT, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public TransactionReceipt set1(BigInteger _creatorId, BigInteger _groupId, String _title, String _content, BigInteger _create) {
        final Function function = new Function(
                FUNC_SET1, 
                Arrays.<Type>asList(new Uint256(_creatorId),
                new Uint256(_groupId),
                new Utf8String(_title),
                new Utf8String(_content),
                new Uint256(_create)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void set1(BigInteger _creatorId, BigInteger _groupId, String _title, String _content, BigInteger _create, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_SET1, 
                Arrays.<Type>asList(new Uint256(_creatorId),
                new Uint256(_groupId),
                new Utf8String(_title),
                new Utf8String(_content),
                new Uint256(_create)),
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForSet1(BigInteger _creatorId, BigInteger _groupId, String _title, String _content, BigInteger _create) {
        final Function function = new Function(
                FUNC_SET1, 
                Arrays.<Type>asList(new Uint256(_creatorId),
                new Uint256(_groupId),
                new Utf8String(_title),
                new Utf8String(_content),
                new Uint256(_create)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple5<BigInteger, BigInteger, String, String, BigInteger> getSet1Input(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_SET1, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple5<BigInteger, BigInteger, String, String, BigInteger>(

                (BigInteger) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (BigInteger) results.get(4).getValue()
                );
    }

    public TransactionReceipt set2(BigInteger _likeCount, BigInteger _collectCount, BigInteger _forwardCount, BigInteger _readCount, BigInteger _update, BigInteger _status) {
        final Function function = new Function(
                FUNC_SET2, 
                Arrays.<Type>asList(new Uint256(_likeCount),
                new Uint256(_collectCount),
                new Uint256(_forwardCount),
                new Uint256(_readCount),
                new Uint256(_update),
                new Uint256(_status)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void set2(BigInteger _likeCount, BigInteger _collectCount, BigInteger _forwardCount, BigInteger _readCount, BigInteger _update, BigInteger _status, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_SET2, 
                Arrays.<Type>asList(new Uint256(_likeCount),
                new Uint256(_collectCount),
                new Uint256(_forwardCount),
                new Uint256(_readCount),
                new Uint256(_update),
                new Uint256(_status)),
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForSet2(BigInteger _likeCount, BigInteger _collectCount, BigInteger _forwardCount, BigInteger _readCount, BigInteger _update, BigInteger _status) {
        final Function function = new Function(
                FUNC_SET2, 
                Arrays.<Type>asList(new Uint256(_likeCount),
                new Uint256(_collectCount),
                new Uint256(_forwardCount),
                new Uint256(_readCount),
                new Uint256(_update),
                new Uint256(_status)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple6<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger> getSet2Input(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_SET2, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple6<BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger>(

                (BigInteger) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue(), 
                (BigInteger) results.get(2).getValue(), 
                (BigInteger) results.get(3).getValue(), 
                (BigInteger) results.get(4).getValue(), 
                (BigInteger) results.get(5).getValue()
                );
    }

    public BigInteger status() throws ContractException {
        final Function function = new Function(FUNC_STATUS, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public String title() throws ContractException {
        final Function function = new Function(FUNC_TITLE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public BigInteger update() throws ContractException {
        final Function function = new Function(FUNC_UPDATE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint256>() {}));
        return executeCallWithSingleValueReturn(function, BigInteger.class);
    }

    public static Article load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new Article(contractAddress, client, credential);
    }

    public static Article deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(Article.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }
}
